package ntit.csie.yongzan.MultiTouchEvent;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Bitmap.Config;
import android.widget.ImageView;

public class PaintView {
	private Paint _paint; 
	private Canvas _canvas;
	private ImageView _context;
	private int _MotionW;
	private int _MotionH;
	Bitmap bm;
	public PaintView(ImageView context,int width,int height) {
		//super(context);
		_context=context;
		_MotionW=width;
		_MotionH=height;
		bm=Bitmap.createBitmap(_MotionW,_MotionH, Config.ARGB_8888);
		
		_canvas=new Canvas(bm);
		_paint=new Paint();
		_paint.setAntiAlias(true);
		_paint.setStrokeWidth(3);
	}
	public void setColor(int c){//Color.YELLOW
		_paint.setColor(c);
	}
	public void paintDrawCross(float startX,float startY ,int c1){
		paintDrawClear();
		_paint.setColor(c1);
		_canvas.drawLine(startX, startY,startX,_MotionH, _paint);
		_canvas.drawLine(startX, startY,startX,0, _paint);
		_canvas.drawLine(startX, startY,0,startY, _paint);
		_canvas.drawLine(startX, startY,_MotionW,startY, _paint);
		_canvas.save(Canvas.ALL_SAVE_FLAG);
		_canvas.restore();
		_context.setImageBitmap(bm);
	}
	public void paintDraw2Cross(float startX,float startY,int c1,float X2,float Y2,int c2){
		paintDrawClear();
		_paint.setColor(c1);
		_canvas.drawLine(startX, startY,startX,_MotionH, _paint);
		_canvas.drawLine(startX, startY,startX,0, _paint);
		_canvas.drawLine(startX, startY,0,startY, _paint);
		_canvas.drawLine(startX, startY,_MotionW,startY, _paint);
		_paint.setColor(c2);
		_canvas.drawLine(X2, Y2,X2,_MotionH, _paint);
		_canvas.drawLine(X2, Y2,X2,0, _paint);
		_canvas.drawLine(X2, Y2,0,Y2, _paint);
		_canvas.drawLine(X2, Y2,_MotionW,Y2, _paint);
		_canvas.save(Canvas.ALL_SAVE_FLAG);
		_canvas.restore();
		_context.setImageBitmap(bm);
	}
	public void paintDrawPoint(float startX,float startY,float stopX,float stopY){
		//_canvas.drawPoint(x, y, _paint);
		_canvas.drawLine(startX, startY, stopX, stopY, _paint);
		_canvas.save(Canvas.ALL_SAVE_FLAG);
		_canvas.restore();
		_context.setImageBitmap(bm);
	}
	public void paintDrawClear(){
		_canvas.drawColor(Color.BLACK);
		_canvas.save(Canvas.ALL_SAVE_FLAG);
		_canvas.restore();
		_context.setImageBitmap(bm);
	}
	
	
}
